package com.dns.framework.page;


public class Pagination {
	
	public static final int MAX_PAGE_SIZE = 500;
	public static final int MAX_RECODE_SIZE = Integer.MAX_VALUE;
	

	private boolean batch;
	private boolean range;
	private boolean needCount = true;
	private boolean onlyCount = false;
	//分页的起始行
	private int start;
	//每页的大小
	private int pageSize;
	//行记录总数
	private int rowCount;
	//当前是哪个页
	private int currPage;

    /**
     * construct function
     * @throws Exception
     */
    public Pagination() throws Exception {
    }


	/**
	 * 页数
	 * @return
	 */
	public int getPageCount() {
		 return (int) Math.ceil((double) getRowCount() / (double) getPageSize());
	}

	public int getRowCount() {
		return rowCount;
	}
	/**
	 * set row count
	 * @param rowCount
	 */
	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
	}


	public int getPageSize() {
		return pageSize;
	}
	/**
	 * set pagesize
	 * @param pageSize
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}


	/**
	 * set batch
	 * @param batch
	 * @throws Exception
	 */


	/**
	 * get curr page
	 * @return int
	 */
	public int getCurrPage() {
		return currPage;
	}
	
	/**
	 * get curr page
	 * @param currPage
	 */
	public void setCurrPage(int currPage) {
		this.currPage = currPage;
	}

	/**
	 * 分页起始点
	 * @return int
	 */
	public int getStart() {
		return getCurrPage() == 1 ? 0 : (getCurrPage() - 1) * getPageSize();
	}


}